package {
	import editro.AntVisualContext;
	import editro.model.ATEConfigModel;
	import flash.display.GradientType;
	import flash.display.Shape;
	import flash.display.SpreadMethod;
	import flash.display.Sprite;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.geom.Matrix;
	import flash.text.Font;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import nl.demonsters.debugger.MonsterDebugger;

	/**
	 * ...
	 * @author LEEF LEE_LEAF918@163.COM_QQ969442267
	 */
	public class Main extends Sprite {
		private var appContext:AntVisualContext;
		private var bgShape:Shape;

		public function Main():void {
			var basicFont:Font = new BasicDots;
			var georgia:Font=new Georgia
			if (stage)
				init();
			else
				addEventListener(Event.ADDED_TO_STAGE, init);
		}

		private function init(e:Event = null):void {
			removeEventListener(Event.ADDED_TO_STAGE, init);
			// entry point
			this.stage.scaleMode = StageScaleMode.NO_SCALE;
			addBgShape();
			new MonsterDebugger(this);
			appContext = new AntVisualContext(this);
			//
			addversionTF();
		}
		
		private function addversionTF():void 
		{
			var versionTf:TextField = new TextField;
			versionTf.autoSize = TextFieldAutoSize.LEFT;
			addChild(versionTf);
			versionTf.background = true;
			versionTf.selectable = false;
			versionTf.text = ATEConfigModel.VERSION;
			versionTf.addEventListener(MouseEvent.MOUSE_OVER,function ():void 
			{
				versionTf.alpha = 1;
			});
			versionTf.addEventListener(MouseEvent.MOUSE_OUT,function ():void 
			{
				versionTf.alpha = 0;
			});
			versionTf.alpha = 0;
		}

		private function addBgShape():void {
			bgShape = new Shape();
			addChild(bgShape);
			var fillType:String = GradientType.RADIAL;
			var colors:Array = [0xddFFdd, 0x99FF99];
			var alphas:Array = [1, 1];
			var ratios:Array = [0x00, 0xFF];
			var matr:Matrix = new Matrix();
			matr.createGradientBox(stage.stageWidth, stage.stageHeight, 0, 0, 0);
			var spreadMethod:String = SpreadMethod.PAD;
			bgShape.graphics.beginGradientFill(fillType, colors, alphas, ratios, matr, spreadMethod);
			bgShape.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
		}
	}
}